home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1995 February / 1995-02b.d64 / money functions (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  1KB  |  35 lines

  1. 100 :
  2. 110 rem money functions on dollars
  3. 120 :
  4. 130 rem note they may be innaccurate on         large numbers due to round-off
  5. 140 rem rd(x) rounds up or down to a            full cent
  6. 150 rem rs(x) raises to next full cent          if there's a fraction of a cent
  7. 160 rem tr(x) truncates, or lops off            any fraction of a cent
  8. 170 rem fr(x) returns only fraction             of a cent
  9. 180 :
  10. 190 def fn rd(x)=int(x*100+.5)/100
  11. 200 :
  12. 210 def fn rs(x)=int(x*100+.9999)/100
  13. 220 :
  14. 230 def fn tr(x)=int(x*100)/100
  15. 240 :
  16. 250 def fn fr(x)=x-int(x*100)/100
  17. 260 :
  18. 270 :
  19. 280 :
  20. 290 rem money functions on pennies
  21. 300 :
  22. 310 rem no roundoff errors, but the             values are pennies, not dollars
  23. 320 rem rd(x) rounds up or down to a            full cent
  24. 330 rem rs(x) raises to next full cent          if there's a fraction of a cent
  25. 340 rem tr(x) truncates, or lops off            any fraction of a cent
  26. 350 rem fr(x) returns only fraction             of a cent
  27. 360 :
  28. 370 def fn rd(x)=int(x+.5)
  29. 380 :
  30. 390 def fn rs(x)=int(x+.99999)
  31. 400 :
  32. 410 def fn tr(x)=int(x)
  33. 420 :
  34. 430 def fn fr(x)=x-int(x)
  35.